package HomeWork3_10;

import java.util.Scanner;

public class HomeWork3_10_1 {
    static int N = (int)(1e5+5);
    static boolean[] prim = new boolean[N];
    public static void pret(){
        prim[1] = true;
        for(int i = 2;i < N;i++)
            for (int j = i*2; j < N; j+=i)
                prim[j] = true;
    }
    public static void main(String[] args) {
        pret();
        System.out.println("请输入要判断的范围是1 ~ ：");
        int n, sum = 0;
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        for(int i = 2;i <= n;i++)
            if(!prim[i])
                sum++;
        System.out.println("一共有" + sum + "个素数：");
        for(int i = 2;i<=n;i++){
            if(!prim[i])
                System.out.println(i);
        }
    }
}
